package shoot.FlyingObject;

import java.awt.image.BufferedImage;

/**
 * @author: dongshipan
 * @date: 2021/7/5 17:03
 * @description:
 */
public class Bullet extends BaseFlyingObject {

    private static BufferedImage image;

    /**
     * 横向移动速度
     */
    private int step;


    static {
        image = readImage("bullet.png");
    }

    public Bullet(int x, int y) {
        super(8, 20, x, y);
        step = FlyConstant.BULLET_STEP;
    }

    public Bullet(int width, int height, int x, int y) {
        super(width, height, x, y);
    }

    @Override
    public void step() {
        y -= step;
    }

    @Override
    public BufferedImage getImage() {
        if (isLife()) {
            return image;
        } else if (isDead()) {
            state = FlyConstant.REMOVE;
        }
        return null;
    }

    @Override
    public boolean outOfBounds() {
        return y < -height;
    }

}
